﻿--[[--
	alex/ALA @ 163UI
	http://wowui.w.163.com/163ui/
--]]--

do		-- get_mana_regen_tick_from_gear
	local mp5_gear = {
		[9448] = 3,
		[10659] = 5,
		[11634] = 3,
		[12637] = 4,
		[13141] = 3,
		[13178] = 5,
		[13179] = 3,
		[13216] = 6,
		[13244] = 4,
		[13383] = 10,
		[13386] = 4,
		[14141] = 8,
		[14142] = 6,
		[14143] = 6,
		[14144] = 8,
		[14154] = 6,
		[14545] = 6,
		[14620] = 4,
		[14621] = 6,
		[14622] = 4,
		[14623] = 5,
		[14624] = 5,
		[16472] = 6,
		[16473] = 5,
		[16474] = 5,
		[16476] = 6,
		[16573] =  5,
		[16797] = 4,
		[16799] = 3,
		[16801] = 4,
		[16812] = 6,
		[16814] = 6,
		[16817] = 4,
		[16819] = 2,
		[16828] = 4,
		[16829] = 3,
		[16833] = 3,
		[16835] = 4,
		[16836] = 4,
		[16838] = 4,
		[16842] = 6,
		[16843] = 6,
		[16844] = 4,
		[16854] = 4,
		[16855] = 3,
		[16857] = 4,
		[16859] = 2,
		[16900] = 6,
		[16901] = 6,
		[16902] = 4,
		[16903] = 4,
		[16914] = 4,
		[16917] = 4,
		[16918] = 4,
		[16922] = 7,
		[16943] = 6,
		[16948] = 6,
		[16953] = 5,
		[16954] = 4,
		[16956] = 6,
		[16958] = 5,
		[17064] = 16,
		[17070] = 4,
		[17105] = 5,
		[17106] = 9,
		[17110] = 3,
		[17113] = 12,
		[17602] = 4,
		[17603] = 4,
		[17605] = 4,
		[17623] = 4,
		[17624] = 4,
		[17625] = 4,
		[17710] = 2,
		[17718] = 4,
		[17741] = 8,
		[17743] = 8,
		[18103] = 5,
		[18104] = 8,
		[18263] = 9,
		[18308] = 7,
		[18311] = 8,
		[18312] = 5,
		[18314] = 6,
		[18327] = 6,
		[18371] = 11,
		[18386] = 6,
		[18468] = 8,
		[18469] = 4,
		[18477] = 8,
		[18483] = 4,
		[18491] = 3,
		[18532] = 10,
		[18536] = 6,
		[18609] = 7,
		[18697] = 4,
		[18726] = 4,
		[18730] = 5,
		[18739] = 5,
		[18743] = 6,
		[18757] = 8,
		[18800] = 12,
		[18803] = 9,
		[18872] = 14,
		[18875] = 9,
		[19038] = 4,
		[19047] = 4,
		[19050] = 6,
		[19096] = 4,
		[19098] = 4,
		[19123] = 4,
		[19131] = 5,
		[19303] = 6,
		[19308] = 3,
		[19312] = 3,
		[19347] = 4,
		[19371] = 9,
		[19373] = 9,
		[19390] = 6,
		[19391] = 12,
		[19395] = 9,
		[19397] = 9,
		[19400] = 5,
		[19430] = 6,
		[19435] = 5,
		[19518] = 4,
		[19519] = 4,
		[19520] = 3,
		[19521] = 2,
		[19522] = 4,
		[19523] = 4,
		[19524] = 3,
		[19525] = 2,
		[19566] = 8,
		[19567] = 7,
		[19568] = 6,
		[19569] = 4,
		[19570] = 8,
		[19571] = 7,
		[19572] = 6,
		[19573] = 4,
		[19831] = 4,
		[19833] = 4,
		[19884] = 14,
		[19903] = 6,
		[19905] = 4,
		[19920] = 6,
		[19923] = 3,
		[19964] = 6,
		[19965] = 6,
		[19967] = 5,
		[19999] = 9,
		[20056] = 4,
		[20061] = 4,
		[20083] = 5,
		[20176] = 4,
		[20203] = 4,
		[20217] = 7,
		[20218] = 6,
		[20257] = 7,
		[20262] = 5,
		[20264] = 4,
		[20265] = 6,
		[20266] = 7,
		[20278] = 2,
		[20325] = 4,
		[20327] = 8,
		[20329] = 8,
		[20331] = 8,
		[20332] = 4,
		[20333] = 4,
		[20334] = 5,
		[20335] = 2,
		[20336] = 4,
		[20380] = 4,
		[20425] = 3,
		[20426] = 2,
		[20431] = 2,
		[20434] = 3,
		[20479] = 6,
		[20480] = 5,
		[20481] = 4,
		[20537] = 4,
		[20538] = 6,
		[20539] = 3,
		[20581] = 11,
		[20618] = 5,
		[20621] = 3,
		[20628] = 8,
		[20631] = 10,
		[20647] = 4,
		[20648] = 3,
		[20685] = 8,
		[20698] = 3,
		[20714] = 4,
		[21179] = 3,
		[21185] = 8,
		[21206] = 3,
		[21207] = 3,
		[21208] = 4,
		[21209] = 4,
		[21210] = 5,
		[21275] = 15,
		[21311] = 6,
		[21344] = 4,
		[21345] = 4,
		[21346] = 5,
		[21348] = 7,
		[21349] = 3,
		[21350] = 3,
		[21352] = 6,
		[21354] = 3,
		[21355] = 4,
		[21356] = 4,
		[21373] = 4,
		[21375] = 4,
		[21376] = 3,
		[21388] = 4,
		[21390] = 4,
		[21391] = 3,
		[21395] = 4,
		[21397] = 5,
		[21401] = 3,
		[21408] = 5,
		[21410] = 4,
		[21411] = 5,
		[21458] = 4,
		[21462] = 5,
		[21481] = 4,
		[21482] = 4,
		[21483] = 3,
		[21496] = 4,
		[21500] = 4,
		[21507] = 6,
		[21517] = 9,
		[21582] = 7,
		[21583] = 8,
		[21587] = 4,
		[21588] = 6,
		[21607] = 5,
		[21610] = 6,
		[21612] = 5,
		[21615] = 11,
		[21619] = 10,
		[21620] = 5,
		[21663] = 7,
		[21666] = 5,
		[21681] = 8,
		[21690] = 6,
		[21696] = 7,
		[21698] = 6,
		[21712] = 6,
		[21801] = 3,
		[21806] = 6,
		[21839] = 3,
		[22079] = 2,
		[22080] = 6,
		[22083] = 6,
		[22084] = 7,
		[22085] = 6,
		[22086] = 4,
		[22087] = 4,
		[22093] = 4,
		[22096] = 4,
		[22098] = 4,
		[22099] = 4,
		[22107] = 2,
		[22112] = 2,
		[22113] = 4,
		[22234] = 3,
		[22254] = 2,
		[22271] = 5,
		[22319] = 4,
		[22326] = 3,
		[22424] = 4,
		[22425] = 10,
		[22426] = 8,
		[22427] = 8,
		[22428] = 8,
		[22429] = 4,
		[22430] = 5,
		[22431] = 5,
		[22436] = 4,
		[22437] = 6,
		[22438] = 3,
		[22441] = 4,
		[22442] = 3,
		[22458] = 7,
		[22464] = 12,
		[22465] = 9,
		[22466] = 8,
		[22467] = 6,
		[22468] = 6,
		[22469] = 6,
		[22470] = 7,
		[22471] = 4,
		[22488] = 8,
		[22489] = 8,
		[22491] = 5,
		[22492] = 5,
		[22494] = 4,
		[22495] = 5,
		[22512] = 5,
		[22514] = 5,
		[22515] = 3,
		[22516] = 6,
		[22517] = 4,
		[22676] = 6,
		[22681] = 4,
		[22713] = 4,
		[22801] = 10,
		[22809] = 8,
		[22819] = 6,
		[22882] = 6,
		[22885] = 6,
		[22947] = 7,
		[22960] = 5,
		[22988] = 5,
		[22994] = 10,
		[23027] = 10,
		[23037] = 10,
		[23048] = 4,
		[23056] = 8,
		[23058] = 6,
		[23065] = 6,
		[23066] = 6,
		[23067] = 6,
		[23075] = 4,
		[23261] = 6,
		[23262] = 6,
		[23302] = 6,
		[23303] = 6,
		[23316] = 6,
		[23317] = 6,
		[23454] = 6,
		[23455] = 7,
		[23464] = 6,
		[23465] = 7,
		[23663] = 5,
		[23666] = 7,
		[23667] = 4,
	};
	local mp5_gear_set_value = {
		3,
		12,
		4,
		4,
		4,
	};
	local mp5_gear_set = {
		[15045] = { 1, 2, 3, },
		[15046] = { 1, 2, 3, },
		[20296] = { 1, 2, 3, },

		[19690] = { 2, 3, 12, },
		[19691] = { 2, 3, 12, },
		[19692] = { 2, 3, 12, },

		[19588] = { 3, 2, 4, },
		[19825] = { 3, 2, 4, },
		[19826] = { 3, 2, 4, },
		[19827] = { 3, 2, 4, },
		[19952] = { 3, 2, 4, },

		[19609] = { 4, 2, 4, },
		[19828] = { 4, 2, 4, },
		[19829] = { 4, 2, 4, },
		[19830] = { 4, 2, 4, },
		[19956] = { 4, 2, 4, },

		[19613] = { 5, 2, 4, },
		[19838] = { 5, 2, 4, },
		[19839] = { 5, 2, 4, },
		[19840] = { 5, 2, 4, },
		[19955] = { 5, 2, 4, },
	};
	-- TODO: enchant & aura
	local mp5_enc = {
		-- 护腕 法力回复 290 +4
		-- 头腿 ZUG 预言的光环 +4
		-- 肩 NAXX 天灾的活力 +5
	};
	local mp5_aura = {
		[24363] = 12,
		[25694] = 3,
		[25941] = 6,
		[16609] = 10,
	};
	function UF.get_mana_regen_tick_from_gear(unit)
		local MP5 = 0;
		local set = {  };
		for slot = 1, 18 do
			if slot ~= 4 then
				-- local itemLink = GetInventoryItemLink(unit, slot);
				-- if itemLink then
				-- 	local stats = GetItemStats(itemLink);
				-- 	if stats then
				-- 		local mp5 = stats["ITEM_MOD_POWER_REGEN0_SHORT"];
				-- 		if mp5 then
				-- 			MP5 = MP5 + mp5 + 1;
				-- 		end
				-- 	end
				-- end
				local id = GetInventoryItemID(unit, slot);
				if id then
					if mp5_gear[id] then
						MP5 = MP5 + mp5_gear[id];
					end
					if mp5_gear_set[id] then
						set[mp5_gear_set[id][1]] = set[mp5_gear_set[id][1]] and (set[mp5_gear_set[id][1]] - 1) or mp5_gear_set[id][2];
					end
				end
			end
		end
		for i = 1, #mp5_gear_set_value do
			if set[i] and set[i] <= 0 then
				MP5 = MP5 + mp5_gear_set_value[i];
			end
		end
		return MP5;
	end
end